package com.example.service.attendance;

import com.example.data.attendance.Attendance;
import com.example.data.attendance.AttendanceBO;
import com.example.repository.AttendanceRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

@Service
public class AttendanceServiceImpl implements AttendanceService {
    private AttendanceRepository attendanceRepository;
    @Autowired
    public AttendanceServiceImpl(AttendanceRepository attendanceRepository){
        this.attendanceRepository = attendanceRepository;
    }

    @Override
    public List<Attendance> getAllAttendance() {
        Attendance attendanceInfo = AttendanceBO.convert(attendanceRepository.getAllAttendance().get(0));
        return Arrays.asList(attendanceInfo);
    }

    @Override
    public List<Attendance> getAttendanceByID(Long empID, Long attendanceID) {
        Attendance attendanceInfo = AttendanceBO.convert(attendanceRepository.getAttendanceByID(empID, attendanceID));
        return Arrays.asList(attendanceInfo);
    }

    @Override
    public List<Attendance> addAttendance(Attendance attendance) {
        Attendance attendanceInfo = AttendanceBO.convert(attendanceRepository.addAttendance(attendance));
        return Arrays.asList(attendanceInfo);
    }

    @Override
    public void deleteAttendance(long attendanceID) {
        attendanceRepository.deleteAttendance(attendanceID);

    }
}
